/**
 * 数组的截取方法
 * slice(start, end)，不改变原数组
 * splice(start, count, element1,element2...)，改变原数组
 *  - start开始索引
 */

/* var array = ["xiaoxu", "xiaoli", "xiaofang", "xiaoxi"];

var result = array.slice(-2, -1);

console.log(result); */

var arr = [1, 2, 3, 2, 1, 1, 3, 4, 2, 5];
/* var result = [];

arr.forEach(element => {
  if (!result.includes(element)) {
    result.push(element);
  }
});

console.log(result); */
for (var i = 0; i < arr.length; ++i) {
  for (var j = i + 1; j < arr.length; ++j) {
    if (arr[i] === arr[j]) {
      arr.splice(j, 1);
      j--;
    }
  }
}
console.log(arr);
